package com.yuan.spring.mongo;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by yeg on 2017/9/4.
 */
public class MongoParam {
    private ThreadLocal<Map<String, Object>> threadEqMap = new ThreadLocal<>();
    private ThreadLocal<Map<String, Object>> threadLteMap = new ThreadLocal<>();
    private ThreadLocal<Map<String, Object>> threadGteMap = new ThreadLocal<>();
    private ThreadLocal<Map<String, Object>> threadGtMap = new ThreadLocal<>();
    private ThreadLocal<Map<String, Object>> threadLtMap = new ThreadLocal<>();

    public MongoParam() {
        threadEqMap.set(new HashMap<>());
        threadLteMap.set(new HashMap<>());
        threadGteMap.set(new HashMap<>());
        threadGtMap.set(new HashMap<>());
        threadLtMap.set(new HashMap<>());
    }


    public MongoParam eq(String key, Object value) {
        Map<String, Object> eqMapValue = threadEqMap.get();
        eqMapValue.put(key, value);
        threadEqMap.set(eqMapValue);
        return this;
    }

    public MongoParam lte(String key, Object value) {
        Map<String, Object> lteMapValue = threadLteMap.get();
        lteMapValue.put(key, value);
        threadLteMap.set(lteMapValue);
        return this;
    }

    public MongoParam gte(String key, Object value) {
        Map<String, Object> gteMapValue = threadGteMap.get();
        gteMapValue.put(key, value);
        threadGteMap.set(gteMapValue);
        return this;
    }

    public MongoParam lt(String key, Object value) {
        Map<String, Object> ltMapValue = threadLtMap.get();
        ltMapValue.put(key, value);
        threadLtMap.set(ltMapValue);
        return this;
    }

    public MongoParam gt(String key, Object value) {
        Map<String, Object> gtMapValue = threadGtMap.get();
        gtMapValue.put(key, value);
        threadGtMap.set(gtMapValue);
        return this;
    }


    public ThreadLocal<Map<String, Object>> getThreadEqMap() {
        return threadEqMap;
    }


    public ThreadLocal<Map<String, Object>> getThreadLteMap() {
        return threadLteMap;
    }


    public ThreadLocal<Map<String, Object>> getThreadGteMap() {
        return threadGteMap;
    }

    public ThreadLocal<Map<String, Object>> getThreadGtMap() {
        return threadGtMap;
    }

    public ThreadLocal<Map<String, Object>> getThreadLtMap() {
        return threadLtMap;
    }
}
